package com.tedu.day05mynatis.mapper;

import com.tedu.day05mynatis.pojo.Comment;
import com.tedu.day05mynatis.pojo.CommentVO1;
import com.tedu.day05mynatis.pojo.CommentVO2;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Insert("INSERT INTO comment(content,created,user_id,weibo_id) VALUES (#{content},#{created},#{userId},#{weiboId})")
    int insertComment(Comment comment);
    @Delete("DELETE FROM comment WHERE id=#{id}")
    int deleteComment(int id);
    @Update("UPDATE comment SET content=#{content},created#{created},weibo_id#{weiboId},user_id#{userId} WHERE id=#{id}")
    int updateComment(Comment comment);
    @Select("SELECT content,user_id userId FROM comment WHERE id=#{id}")
    CommentVO1 selectCommentBy(int id);
    @Select("SELECT id,content,user_id userId FROM comment WHERE user_id=#{userId}")
    List<CommentVO2> selectCommentByIdUserId(int userId);
}
